<!DOCTYPE html>
<html lang="en">
<head>
    <title>个人管理层</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=4a6c1b54">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>
    <style>
        .reginTd{
            max-width: 105px;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
            position: relative;
        }
        .div-td-content-more{
            position:absolute;
            height:auto;
            z-index:999;
            line-height:20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display:none;
        }
        .div-td-content-more i{
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left:50px;
            top:-12px;
        }
        .row {
            margin-right: -15px;
            margin-left: 0px;
        }
        .col-lg-6,.col-xs-6,.col-md-6{
            padding-left: 0;
        }
    </style>
</head>
<body>
<section class="content"  id="app" >
    <div class="div-td-content-more"><i></i></div>
    <div class="nav-tabs-custom oaReportNav" v-vloak>
        <!-- Tabs within a box -->
        <ul class="nav nav-tabs pull-right" style="margin-bottom: 10px;">
            <li :class="isActive(today)?'active':''"  @click="refreshData('visitCustomer','get_visitCompany',today)"><a href="#sales-chart" data-toggle="tab">今日</a></li>
            <li :class="isActive(yesterday)?'active':''"  @click="refreshData('visitCustomer','get_visitCompany',yesterday)"><a href="#sales-chart" data-toggle="tab">昨日</a></li>
            <li :class="isActive(thisWeek)?'active':''"  @click="refreshData('visitCustomer','get_visitRegion',today)"><a href="#sales-chart" data-toggle="tab">本周</a></li>
            <li :class="isActive(thisMonth)?'active':''" @click="refreshData('visitCustomer','get_visitRegion',thisMonth)"> <a href="#sales-chart" data-toggle="tab">本月</a></li>
            <li :class="isActive(item.time)?'active':''" v-for="(item,i) in tab"  @click="refreshData('visitCustomer','get_visitRegion',item.time)"><a href="#sales-chart" data-toggle="tab">{{i==0?"上月":item.str}}</a></li>
        </ul>
    </div>
    <div class="div-td-content-more"><i></i></div>
    <div style="padding: 0 10px;background: #fff;overflow: hidden;display: flex;justify-content: space-between;" id="visitCompany">
        <div style="width: 49%;" class="mScrollBox" >
            <table class="table table-bordered text-center table-width" >
                <thead>
                <tr>
                    <th style="width: 85px;">面访排名<div v-if="visitCustomer.time==today&&hour<12">(昨日)</div></th>
                    <th style="width:85px" v-if="visitCustomer.time!=today">日均完成</th>
                    <th style="width: 50px;">完成<div v-if="visitCustomer.time==today&&hour<12">(昨日)</div></th>
                    <th style="width: 50px;">目标</th>
                    <th style="width: 70px;">姓名</th>
                    <th style="width:85px" v-if="visitCustomer.time!=today">出勤天数</th>
                    <th style="width: 280px;">区域</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in visitCustomer.faceList">
                    <td>{{item.rownum}}</td>
                    <td v-if="visitCustomer.time!=today">{{item.averageComplete}}</td>
                    <td v-if="userId==item.managerId" style="color:#169BD5;cursor: pointer" @click="lookInterview(item,'1')">
                        {{item.complete}}
                    </td>
                    <td v-else>-</td>
                    <td>
                        {{item.target}}
                    </td>
                    <td >{{item.userName}}</td>
                    <td v-if="visitCustomer.time!=today">{{item.signManagerNum}}</td>
                    <td class="lineOne"><span>{{item.regionName}}</span></td>
                </tr>
                </tbody>
            </table>
        </div>
        <div  style="width: 49%;float:right;" class="mScrollBox" >
            <table class="table table-bordered text-center table-width" >
                <thead>
                <tr>
                    <th style="width: 85px;">电访排名<div v-if="visitCustomer.time==today&&hour<12">(昨日)</div></th>
                    <th style="width:85px" v-if="visitCustomer.time!=today">日均完成</th>
                    <th style="width: 50px;">完成<div v-if="visitCustomer.time==today&&hour<12">(昨日)</div></th>
                    <th style="width: 50px;">目标</th>
                    <th style="width: 70px;">姓名</th>
                    <th style="width:85px" v-if="visitCustomer.time!=today">出勤天数</th>
                    <th style="width: 280px;">区域</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in visitCustomer.telList">
                    <td>{{item.rownum}}</td>
                    <td v-if="visitCustomer.time!=today">{{item.averageComplete}}</td>
                    <td v-if="userId==item.managerId" style="color:#169BD5;cursor: pointer" @click="lookInterview(item,'0')">
                        {{item.complete}}
                    </td>
                    <td v-else>-</td>
                    <td>
                        {{item.target}}
                    </td>
                    <td >{{item.userName}}</td>
                    <td v-if="visitCustomer.time!=today">{{item.signManagerNum}}</td>
                    <td class="lineOne"><span>{{item.regionName}}</span></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=602456c3"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=6348cbbc"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/highcharts/highcharts.js"></script>
<script type="text/javascript">
    $(function () {
        $("body").on("click",".reginTd",function(e) {
            var text =$(this).text();
            if(text != "") {
                text="<i></i>"+text;
                $(".div-td-content-more").html(text).css({
                    "width": $(this).outerWidth() + "px",
                    "left": $(this).offset().left,
                    "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                }).show();
                e.stopPropagation();
            }
        });
        $("body").on("click",".div-td-content-more",function (e) {
            e.stopPropagation();
        });
        $("body").on("click",function () {
            $(".div-td-content-more").hide();
        });
    });

</script>
<script type="text/javascript">
    console.log(urlConfig);
    var app = new Vue({
        el:'#app',
        data: {
            currentUser: getCurrentUser(),
            departId: $.wyui.page.urlParams.departId,
            months: [],
            dateTime: $.wyui.page.urlParams.dateTime,
            yesterday:new Date(new Date()-24*60*60*1000).Format("yyyy-MM-dd"),
            today: new Date().Format("yyyy-MM-dd"),
            thisMonth: new Date().Format("yyyy-MM"),
            thisWeek: new Date().Format("yyyy-MM-dd") + "-w",
            hour: new Date().getHours(),
            tab: [],
            visitCustomer: {
                time: $.wyui.page.urlParams.dateTime,
                faceList: [],
                telList: [],
            },
        },
        methods:{
            //tab中点击日期刷新对应数据
            refreshData:function (dataType,fun,time) {
                var that=this;
                that[dataType].time=time;
                that[fun]();
            },
            //获取tab
            getTab: function () {
                var that = this;
                var dateTime = new Date().Format("yyyyMM");

                for (var i = 0; i < 5; i++) {
                    dateTime = that.getLastEndMonth(dateTime);
                    that.tab.push(that.insert_flg(dateTime, "-", "4"))
                }
                console.log(that.tab)
            },
            isActive:function (item) {
                var that=this;
                if(that.visitCustomer.time==item){
                    return true;
                }
            },
            getLastEndMonth:function(beginYearMonth){
                var strYear = parseInt(beginYearMonth.substr(0,4),10);
                var strMonth = parseInt(beginYearMonth.substr(4,6),10);
                if(strMonth - 1 == 0){
                    strYear -= 1;
                    strMonth = 12;
                } else {
                    strMonth -= 1;
                }
                if(strMonth<10){
                    strMonth="0"+strMonth;
                }
                var monthstr = strYear+""+strMonth;
                return monthstr;
            },
            //格式化日期
            insert_flg: function (str, flg, sn,type) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                var st1=newstr.substr(2,2);
                var st2=newstr.substr(5,2);
                var newstr3=st2+"/"+st1;
                var obj={str:newstr,time:newstr};
                return obj;
            },
            getCount:function (arr,key) {
                var number=0;
                for (var i = arr.length - 1; i >= 0; i--) {
                    number+=(arr[i][key]&&arr[i][key]!='-'?arr[i][key]:0)

                }
                return number;
            },
            getAllCounnt:function (arr,type) {
                if(type=="1"){
                    this.calculation[1].targetDayCount=this.getCount(arr,"target");
                    this.calculation[1].finishDayCount=this.getCount(arr,"complete");
                    this.calculation[1].managerTargetNum=this.getCount(arr,"managerTargetNum");
                    this.calculation[1].regionManagerNum=this.getCount(arr,"regionManagerNum");
                    this.calculation[1].leaveNumber=this.getCount(arr,"leaveNumber");
                    this.calculation[1].daily=(this.calculation[1].finishDayCount/this.calculation[1].regionManagerNum).toFixed(2);
                    if(this.calculation[1].targetDayCount==0){
                        this.calculation[1].completionRate="0.00%";
                    }else{
                        this.calculation[1].completionRate=(this.calculation[1].finishDayCount/this.calculation[1].targetDayCount*100).toFixed(2)+"%";
                    }
                }else{
                    this.calculation[0].targetDayCount=this.getCount(arr,"target");
                    this.calculation[0].finishDayCount=this.getCount(arr,"complete");
                    this.calculation[0].managerTargetNum=this.getCount(arr,"managerTargetNum");
                    this.calculation[0].regionManagerNum=this.getCount(arr,"regionManagerNum");
                    this.calculation[0].leaveNumber=this.getCount(arr,"leaveNumber");
                    this.calculation[0].daily=(this.calculation[0].finishDayCount/this.calculation[0].regionManagerNum).toFixed(2);
                    if(this.calculation[0].targetDayCount==0){
                        this.calculation[0].completionRate="0.,l00%";
                    }else{
                        this.calculation[0].completionRate=(this.calculation[0].finishDayCount/this.calculation[0].targetDayCount*100).toFixed(2)+"%";
                    }
                }
                console.log(this.calculation)
            },
            //获取拜访报表-区域经理
            get_visitRegion: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.visitCustomer.getForPersonal, {
                    "userId": that.userId,
                    "dateTime": that.visitCustomer.time,
                    "type": "1"
                }, function (data) {
                    var data=trimRN2(data);
                    that.visitCustomer.faceList = data;
                },false,"#visitRegion");
                $.wyui.postMethod(urlConfig.report.visitCustomer.getForPersonal, {
                    "userId": that.userId,
                    "dateTime": that.visitCustomer.time,
                    "type": "0"
                }, function (data) {
                    var data=trimRN2(data);
                    that.visitCustomer.telList = data;
                },false,"#visitRegion");
            },
        },
        mounted:function () {
            var that=this;
            //获取前5个月 拼接出日期筛选框
            //查看参数
            if(!that.userId){
                that.userId=getCurrentUser().userId;
            }
            if(!that.dateTime){
                that.dateTime=new Date().Format("yyyy-MM-dd");
            }
            //获取前5个月的tab数据
            this.getTab();
            //获取数据
            that.get_visitRegion();
        }

    });
</script>
</body>
</html>